package midone.exchangeskill.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

import javax.inject.Inject;


/**
 * Created by 想法的猫 on 2016/8/29.
 */
public class NetWorkUtil {
    @Inject
    Context context;

    public NetWorkUtil(Context context) {
        this.context = context;
    }

    /**
     * 挡墙网络是否可用
     *
     * @return
     */
    public boolean isNetWorkConnect() {
        // 获取手机当前可用的网络连接
        ConnectivityManager connectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        // 获取NetworkInfo对象
        NetworkInfo networkInfo = connectivityManager.getActiveNetworkInfo();
        return networkInfo != null;
    }


}
